<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <title>添加院系管理</title>
</head>
	<style type="text/css">
   			.layui-form{
		        height: 250px;
		       padding-top: 50px;
		    }
		    .buttonOne{
		       width: 50%;
		       height: 40px;
		       margin-top: 190px;
		       padding-left: 40%;
		    }
		    .buttonOne button{
		        margin-left: 20px;
		    }
		    .layui-input, .layui-textarea{
		        width: 70%;
		    }
		    .layui-form-label{
		        padding: 9px 30px;
		    }
   		</style>
<body>
    <form id="form">
            <div class="layui-form-item">
                    <label class="layui-form-label">院系名称</label>
                    <div class="layui-input-block">
                      <input type="text" required  lay-verify="required" placeholder="请输入院系名称" autocomplete="off" class="layui-input" name="department">
                    </div>
                  </div>
            <div class="layui-form-item">
                <div class="layui-input-block buttonOne">
                    <button class="btn layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-normal">重置</button>
                </div>
            </div>
    </form> 
</body>
<script>
    $(function () {       
		$(".btn").click( function () {
			var url="${pageContext.request.contextPath}/depAdd";
			var param=$("#form").serialize();
			$.post(url,param,function(data){
			 	if(data.flag==0){
					alert(data.msg);
				}
				if(data.flag==1){
					window.parent.location.reload();//刷新父页面
			        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
			        parent.layer.close(index);
			        alert(data.msg);
				} 
			});
		});
    });
</script>
</html>